<?php
namespace app\model;

class ScoreDetail extends BaseModel
{
    protected $name = 'score_details';

    // 自动时间戳
    protected $autoWriteTimestamp = true;

    // 类型转换
    protected $type = [
        'answer_time' => 'integer',
        'created_at' => 'integer',
        'updated_at' => 'integer',
        'delete_time' => 'integer'
    ];

    /**
     * 关联用户
     */
    public function user()
    {
        return $this->belongsTo(User::class);
    }

    /**
     * 关联学习记录
     */
    public function learningRecord()
    {
        return $this->belongsTo(LearningRecord::class, 'learning_record_id');
    }

    /**
     * 关联教案元素
     */
    public function element()
    {
        return $this->belongsTo(TeachingPlanElement::class, 'element_id');
    }

    /**
     * 关联聊天消息
     */
    public function message()
    {
        return $this->belongsTo(ChatMessage::class, 'message_id');
    }
} 